/**

 * @File RollUpGroupController.java
 * @author Dhruv Bhandari
 * @Version 1.0
 * @Date June 27, 2013
 * 
 * Copyright (c) 2011 EdRP, Dayalbagh Educational Institute.
 * All Rights Reserved.
 *
 * Redistribution and use in source and binary forms, with or
 * without modification, are permitted provided that the following
 * conditions are met:
 *
 * Redistributions of source code must retain the above copyright
 * notice, this  list of conditions and the following disclaimer.
 *
 * Redistribution in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in
 * the documentation and/or other materials provided with the
 * distribution.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL ETRG OR ITS CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL,SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * Contributors: Members of EdRP, Dayalbagh Educational Institute
 */




package in.ac.dei.edrp.generalLedger.rollUpGroup;




import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.flex.remoting.RemotingDestination;
import org.springframework.stereotype.Controller;

import flex.messaging.FlexContext;
import flex.messaging.FlexSession;

@Controller
@RemotingDestination("rollUpGroupDestination")

public class RollUpGroupController 
{
@Autowired
@Qualifier("RollUpGroupDaoImpl")
private RollUpGroupDao rollUpGroupDao;

	public List<RollUpGroupBean> getAllRollUpGroup(Map<String, String> obj)
	
	{  
		RollUpGroupBean bean = new RollUpGroupBean();
		bean.setSegmentId(obj.get("segmentId"));
		List<RollUpGroupBean> list = rollUpGroupDao.getAllRollUpGroup(bean);
		return list; 
	}
	public String setRollUpGroup(Map<String, String> obj,String flag)
	{   FlexSession session = FlexContext.getFlexSession();
	System.out.println("setRollUpGroup" );
		String str = "";
		RollUpGroupBean bean = new RollUpGroupBean();
		bean.setOldRollUpGroupCode(obj.get("oldRollUpGroupCode"));
		bean.setApplicationId(session.getAttribute("applicationId").toString());
		bean.setSegmentId(obj.get("segmentId"));
		bean.setFlexFieldId(obj.get("flexFieldId"));
		bean.setFlexFieldCode(obj.get("flexFieldCode"));
		bean.setRollUpGroupCode(obj.get("rollUpGroupCode"));
		bean.setOrganizationId(session.getAttribute("universityCode").toString());
		bean.setUserId(session.getAttribute("userId").toString());
     	bean.setRollUpGroupName(obj.get("rollUpGroupName"));
     	bean.setFlag(obj.get("flag"));
		bean.setRollUpGroupDescription(obj.get("rollUpGroupDescription"));
		str= rollUpGroupDao.setRollUpGroup(bean,flag);
		return str;
		
		
	}
	
	public String deleteRollUpGroup(Map<String, String> obj)
	{    
		String str = "";
		System.out.println("deleteRollUpGroup" );
		RollUpGroupBean bean = new RollUpGroupBean();
		bean.setSegmentId(obj.get("segmentId"));
		bean.setRollUpGroupCode(obj.get("rollUpGroupCode"));
     	bean.setRollUpGroupName(obj.get("rollUpGroupName")); 
		bean.setRollUpGroupDescription(obj.get("rollUpGroupDescription"));
		str= rollUpGroupDao.deleteRollUpGroup(bean);
		return str;
		
		
	}
	
	public List<RollUpGroupBean> setSegmentCode(Map<String, String> obj)
	{ 
		System.out.println("setSegmentCode" );
		List<RollUpGroupBean> list = new ArrayList<RollUpGroupBean>();
		FlexSession session = FlexContext.getFlexSession();
		RollUpGroupBean bean = new RollUpGroupBean();
		bean.setOrganizationId(session.getAttribute("universityCode").toString());
		list = rollUpGroupDao.setSegmentCode(bean);
        return list;	
	}
	
	
	public List<RollUpGroupBean> getFlexFieldName()
	{ 
		System.out.println("getFlexFieldName" );
		List<RollUpGroupBean> list = new ArrayList<RollUpGroupBean>();
		FlexSession session = FlexContext.getFlexSession();
		RollUpGroupBean bean = new RollUpGroupBean();
		bean.setOrganizationId(session.getAttribute("universityCode").toString());
		list = rollUpGroupDao.getFlexFieldName(bean);
        return list;	
	}
	
	
	public List<RollUpGroupBean> getFlexFieldCode()
	{ 
		List<RollUpGroupBean> list = new ArrayList<RollUpGroupBean>();
		FlexSession session = FlexContext.getFlexSession();
		RollUpGroupBean bean = new RollUpGroupBean();
		bean.setOrganizationId(session.getAttribute("universityCode").toString());
		list = rollUpGroupDao.getFlexFieldCode(bean);
        return list;	
	}
	
	public List<RollUpGroupBean> getSegmentValue(Map<String, String> obj)
	{ 
		
		List<RollUpGroupBean> list = new ArrayList<RollUpGroupBean>();
		FlexSession session = FlexContext.getFlexSession();
		RollUpGroupBean bean = new RollUpGroupBean();
		bean.setRollUpGroupCode(obj.get("rollUpGroupCode"));
		bean.setSegmentId(obj.get("segmentId"));
		list = rollUpGroupDao.getSegmentValue(bean);
        return list;	
	}

}

